//--------------------------------------------------------------
//
// Qizhi Zhang 
// ezhung@gmail.com
// http://www.moorwind.com
//
//--------------------------------------------------------------
package reader.controller
{
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.command.SimpleCommand;
	
	import reader.ApplicationFacade;
	import reader.core.ReaderModelLocator;
	import reader.view.BlogListMediator;
	import reader.view.BlogSummaryMediator;
	import reader.view.ControlBannerMediator;
	import reader.view.LabelTreeMediator;
	import reader.view.SearchResultMediator;

	public class InitDataCommand extends SimpleCommand implements ICommand
	{
		////////////////////////////////////////////////////////////////////////////////
		//private variables
		
		private var airReader:Reader;
		private var readerModelLocator:ReaderModelLocator = ReaderModelLocator.instance;
		
		//////////////////////////////////////////////////////////////////////////////
		//methods
		override public function execute(notification:INotification):void
		{
			airReader = notification.getBody() as Reader; 
					
			facade.registerMediator(new LabelTreeMediator(airReader.labelTree));
			facade.registerMediator(new ControlBannerMediator(airReader.controlBanner));
			facade.registerMediator(new BlogSummaryMediator(airReader.blogSummary));
			facade.registerMediator(new BlogListMediator(airReader.blogListBox));
			facade.registerMediator(new SearchResultMediator(airReader.feedSearchResult));
			facade.registerCommand(ApplicationFacade.LABEL_CREATE, AddLabelCommand);
			facade.registerCommand(ApplicationFacade.SUBSCRIBE_CREATE, AddSubscribeCommand);
			facade.registerCommand(ApplicationFacade.RENAME_SUBSCRIBE, RenameSubscribeCommand);
			facade.registerCommand(ApplicationFacade.REMOVE_SUBSCRIBE, RemoveSubscribeCommand);
			facade.registerCommand(ApplicationFacade.SEARCH_SUBSCRIBE, OpenSearchResultCommand);
			facade.registerCommand(ApplicationFacade.DELETE_ACCOUNT, DeleteAccountCommand);
			
			sendNotification(ApplicationFacade.CREATE_LABEL_TREE);
			sendNotification(ApplicationFacade.FETCH_SERVICES);
		}
		
	}
}